<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>优惠券的注册页面</title>
    <link rel="stylesheet" href="css/CouponAdminRegister.css">
</head>

<body>
    <div id="app">
        <img src="../CouponAdmin/img/register_logo.png" class="logo">
        <div class="header">
            <img src="../CouponAdmin/img/背景图.jpg">
            <div class="register">
                <a class="revoke" href="../CouponAdmin/CouponAdminLogin.html">
                    <</a> <p>新用户注册</p>
                        <div class="content">
                            <span>账 号 ：</span>
                            <el-input type="text" v-model="username" placeholder="请输入你的用户名" class="text"></el-input>
                            <span>密 码 ：</span>
                            <el-input type="text" placeholder="请输入密码" v-model="password" show-password class="text">
                            </el-input>
                            <span>手机号 :</span>
                            <el-input type="text" placeholder="请输入你的手机号" v-model="userTelno" class="phone"></el-input>
                            <span>权 限 ： </span>
                            <!-- <select class="selectpower" v-model="select">
                        <option aria-checked="true" selected = "selected">      -----请选择：商家1/平台0----</option>
                        <option >0</option>
                        <option>1</option>
                    </select> -->
                            <el-select v-model="select" clearable placeholder="请选择：商家1/平台0" class="selectpower">
                                <el-option v-for="item in options" :key="item.value" :label="item.label"
                                    :value="item.value">
                                </el-option>
                            </el-select>
                            <span>编 号 ：</span>
                            <el-input type="text" placeholder="请输入酒店编号" v-model="hotelNo" class="hotelno"></el-input>
                        </div>
                        <el-checkbox v-model="isAgree" style="top:40px;" class="agree">同意用户协议和隐私政策</el-checkbox>
                        <el-button type="success" class="registerBtn" @click="submit">注册</el-button>
            </div>
        </div>
    </div>


    <!--引用vue.js文件-->
    <script src="../CouponAdmin/util/vue.js"></script>
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <!--引用axius异步请求封装-->
    <script src="../CouponAdmin/util/axios-0.18.0.js"></script>
    <!--引用element-ui-->
    <script src="../CouponAdmin/util/index.js"></script>
    <script>
        new Vue({
            el: '#app',
            data() {
                return {
                    username: '', //用户名
                    password: '', //密码
                    userTelno: '', //手机号
                    select: '', //选择卡
                    hotelNo: 0, // 酒店编号
                    isAgree: false, //是否接收协议

                    options: [{
                        value: '0',
                        label: '平台'
                    }, {
                        value: '1',
                        label: '商家'
                    }],
                }
            },
            methods: {
                submit() {
                    if (this.username == '') {
                        alert("用户名不能为空！")
                        return
                    }
                    if (this.password == '') {
                        alert("密码不能为空！")
                        return
                    }
                    if (this.userTelno == '') {
                        alert("手机号不能为空！")
                        return
                    }
                    if (this.select == null) {
                        alert("请选择权限！")
                        return
                    }
                    if (this.hotelNo == '') {
                        alert("酒店编号不能为空！")
                        return
                    }
                    if (!this.isAgree) {
                        alert("请勾选协议！");
                        return
                    }
                    this.register();


                },
                register() {
                    // debugger
                    var that = this
                    console.log("身份" + that.select)
                    console.log("酒店编号" + that.hotelNo)
                    var userInfo = {
                        userAdmin: that.username,
                        userNo: that.hotelNo,
                        userPwd: that.password,
                        userPower: that.select,
                        userTelno: that.userTelno

                    }
                    axios({
                        method: "post",
                        url: "http://localhost:8080/couponAdmin/registerCouponAdmin",
                        data: userInfo
                    }).then(function (resp) {
                        console.log(resp);
                        if (resp.data.code == 200) window.location.href = "CouponAdminLogin.html"
                        else return
                    })

                }

            },
            mounted() {},
        })
    </script>

</body>

</html>